const information = document.getElementById('info');
information.innerText = `This app is using Chrome (v${window.versions.chrome()}), Node.js (v${window.versions.node()}), and Electron (v${window.versions.electron()})`;

const func = async () => {
    const response = await window.versions.ping();
    console.log(response);
}

func();

const btn = document.getElementById('btn');
const filePathElement = document.getElementById('filePath');

btn.addEventListener('click', async () => {
    const filePath = await window.versions.openFile();
    filePathElement.innerText = filePath;
});

const setButton = document.getElementById('btn3');
const titleInput = document.getElementById('title');
setButton.addEventListener('click', () => {
  const title = titleInput.value;
  window.versions.setTitle(title);
})

const counter = document.getElementById('counter');

window.versions.onUpdateCounter((value) => {
  const oldValue = Number(counter.innerText);
  const newValue = oldValue + value;
  counter.innerText = newValue.toString();
  window.versions.counterValue(newValue);
})